﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Zzj.Model;

namespace Zzj.Windows
{
    /// <summary>
    /// StatementWindow.xaml 的交互逻辑
    /// </summary>
    public partial class StatementWindow : Window
    {
        private ImageBrush imageBrush;
        private SynchronizationContext _syncContext = null;
        private BillModel billModel = null;

        private String message = null;

        public StatementWindow()
        {
            InitializeComponent();

            message = App.getConfig().statementMessage;
            _syncContext = SynchronizationContext.Current;

            this.Loaded += Winndow_Loaded;
        }

        private void Winndow_Loaded(object sender, RoutedEventArgs e)
        {
            txtMessage.Text = message;
        }

        public void setPersonImage(ImageBrush image)//获取身份证照片
        {
            signingDate.Text = DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss");//签订日期时间
            this.imageBrush = image;
            this.cardImagePanel.Background = image;
        }

        public void setBillModel(BillModel billModel)//获取对象值
        {
            this.billModel = billModel;
            this.DataContext = billModel;
        }

        private void closeWindow(object sender, RoutedEventArgs e)
        {
            //容器Grid
            Grid grid = this.Owner.Content as Grid;
            //父级窗体原来的内容
            UIElement original = VisualTreeHelper.GetChild(grid, 0) as UIElement;
            //将父级窗体原来的内容在容器Grid中移除
            grid.Children.Remove(original);
            //赋给父级窗体
            this.Owner.Content = original;
            this.DialogResult = false;
            this.Close();
        }

        private void click_agreee(object sender, RoutedEventArgs e)
        {
            Grid grid = this.Owner.Content as Grid;
            //父级窗体原来的内容
            UIElement original = VisualTreeHelper.GetChild(grid, 0) as UIElement;
            //将父级窗体原来的内容在容器Grid中移除
            grid.Children.Remove(original);
            //赋给父级窗体
            this.Owner.Content = original;
            this.DialogResult = true;
            this.Close();
        }

        private void changeButtonEnable(object sender, RoutedEventArgs e)
        {
            agreeButton.IsEnabled = true;
        }

        private void changeButtonUnenable(object sender, RoutedEventArgs e)
        {
            agreeButton.IsEnabled = false;
        }
    }
}